package com.cow.framework.core.config.parameter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.cow.framework.core.cache.RedisUtil;
 
/**
 * 系统参数初始化
 *
 * @author yangsj
 */
@Component
public class ParameterSchedule{
	@Autowired
	protected RedisUtil redisUtil;
	@Autowired
	ParameterDAO parameterDAO;
	
	@Scheduled(initialDelay=1000, fixedRate=3600000) 
    public void init(){
    	List<Parameter> parameterList = parameterDAO.findAll();
    	Map<String,String> parameterMap = new HashMap();
    	for(Parameter p:parameterList){
    		parameterMap.put(p.getCode(), p.getValue());    		
    	}
    	
    	redisUtil.set("sys_parameterMap", parameterMap);
    }	
}
